package com.ihighest.app.infox.myview;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ihighest.app.infox.R;

public class SettingImgView extends RelativeLayout {
	private TextView item;
	private ImageView itemImg;
	private ImageView rightImg;

	public SettingImgView(Context context, AttributeSet attrs, String name, boolean icheck) {
		super(context, attrs);
		initView(context);
		TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SettingImgView);
		String itemName = a.getString(R.styleable.SettingImgView_imgItemName);
		setItemName(itemName);
		// Constants.changeSize(context, this, true);
		a.recycle();
	}

	public SettingImgView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		// Constants.changeSize(context, this, true);
	}

	public SettingImgView(Context context, AttributeSet attrs) {
		super(context, attrs);
		initView(context);
		TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SettingImgView);
		String itemName = a.getString(R.styleable.SettingImgView_imgItemName);
		itemImg.setImageDrawable(a.getDrawable(R.styleable.SettingImgView_imgPath));
		// 2表示gone 0=visiable,1=invisiable
		if (a.getInt(R.styleable.SettingImgView_rightVisiable, 2) == 0) {
			rightImg.setVisibility(View.VISIBLE);
		} else {
			rightImg.setVisibility(View.GONE);
		}

		// rightImg.setVisibility(a.getInt(R.styleable.SettingImgView_rightVisiable,
		// 2));
		setItemName(itemName);
		// Constants.changeSize(context, this, true);
		a.recycle();
	}

	/**
	 * 设置条目
	 * 
	 * @param itemName
	 * 
	 * @author lkx Created at 2015-10-5 上午9:14:08
	 */
	public void setItemName(String itemName) {
		item.setText(itemName);

	}

	public SettingImgView(Context context) {
		super(context);
		initView(context);
	}

	/**
	 * 初始化绑定控件
	 * 
	 * @param context
	 * 
	 * @author lkx Created at 2015-10-5 上午8:58:56
	 */
	private void initView(Context context) {
		View view = View.inflate(context, R.layout.infox_myview_imgitem, this);
		item = (TextView) view.findViewById(R.id.mSettingImgItem);
		item.setTextSize(16.0f);
		itemImg = (ImageView) view.findViewById(R.id.mSettingImgPath);
		rightImg = (ImageView) view.findViewById(R.id.mSettingImgRight);
	}

	/**
	 * @return the item
	 */
	public TextView getItem() {
		return item;
	}

	/**
	 * @return the itemImg
	 */
	public ImageView getItemImg() {
		return itemImg;
	}

	/**
	 * @return the rightImg
	 */
	public ImageView getRightImg() {
		return rightImg;
	}

}
